package proxy;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author shenhan
 * @create 2020/1/17 10:20
 * @description
 */
public class PersonMethonInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        doBefore();
        final Object invokeSuper = proxy.invokeSuper(obj, args);
        doAfter();
        return invokeSuper;
    }

    private void doAfter() {
        System.out.println("饭后擦擦手！");
    }

    private void doBefore() {
        System.out.println("饭前先洗手！");
    }
}
